SML=/usr/local/smlnj-110.71
CHAP=chap4
ARCH=x86-darwin

compile :	
		$(SML)/bin/ml-build sources.cm Parse.main

test :		testast testup

testast :	
		-$(RM) -rf ast
		/bin/mkdir ast
		-( cd ../testcases ; \
		   for i in *.tig ;  \
		   do           \
			$(SML)/bin/sml @SMLload=../$(CHAP)/sources                 \
				       -a                                          \
				       $$i                                         \
				       > ../$(CHAP)/ast/`basename $$i .tig`.ast    \
				       2> ../$(CHAP)/ast/`basename $$i .tig`.err ; \
		   done )

testup :	
		-$(RM) -rf up upup
		/bin/mkdir up upup
		-( cd ../testcases ; \
		   for i in *.tig ;  \
		   do           \
			$(SML)/bin/sml @SMLload=../$(CHAP)/sources                \
				       -u                                         \
				       $$i                                        \
				       > ../$(CHAP)/up/$$i                        \
				       2> ../$(CHAP)/up/`basename $$i .tig`.err ; \
		   done )
		-( cd up ; \
		   for i in *.tig ;  \
		   do           \
			$(SML)/bin/sml @SMLload=../sources                  \
				       -u                                   \
				       $$i                                  \
				       > ../upup/$$i                        \
				       2> ../upup/`basename $$i .tig`.err ; \
		   done )
		   diff -r up upup


clean :
		-$(RM) -rf sources.$(ARCH) ast up upup *~ tiger.grm.* tiger.lex.* .cm